﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using LavenderSoftware.D3ALoader.Agents;
//using LavenderSoftware.D3ALoader.Model;

namespace LavenderSoftware.D3ALoader.ViewModel
{
    /// <summary>
    /// This class contains properties that the main View can data bind to.
    /// <para>
    /// Use the <strong>mvvminpc</strong> snippet to add bindable properties to this ViewModel.
    /// </para>
    /// <para>
    /// See http://www.galasoft.ch/mvvm/getstarted
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase
    {

        private RelayCommand _launchCommand;

        /// <summary>
        /// Gets the LaunchCommand.
        /// </summary>
        public RelayCommand LaunchCommand
        {
            get
            {
                return _launchCommand
                    ?? (_launchCommand = new RelayCommand(
                        () =>
                        {
                            D3AInjectionAgent.InstallD3A(Path, "-launch");
                        }));
            }
        }
        //  private readonly IDataService _dataService;

        ///<summary>
        ///The <see cref="Path" /> property's name.
        ///</summary>
        public const string PathPropertyName = "Path";

        private string _path = string.Empty;

        /// <summary>
        ///Gets the Path property.
        ///Changes to that property's value raise the PropertyChanged event. 
        /// </summary>
        public string Path
        {
            get
            {
                return _path;
            }

            set
            {
                if (_path == value)
                {
                    return;
                }

                _path = value;
                RaisePropertyChanged(PathPropertyName);
            }
        }

        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        //public MainViewModel(IDataService dataService)
        //{
        //    _dataService = dataService;
        //    _dataService.GetData(
        //        (item, error) =>
        //        {
        //            if (error != null)
        //            {
        //                // Report error here
        //                return;
        //            }

        //            WelcomeTitle = item.Title;
        //        });
        //}

        ////public override void Cleanup()
        ////{
        ////    // Clean up if needed

        ////    base.Cleanup();
        ////}
    }
}